
public class Motor implements Comparable<Motor>{
	private String serialNumber;
	private int maximumHoursBeforeService;
	private int currentHours;
	
	public Motor(String inSerial, int maximumHours) {
		serialNumber = inSerial;
		maximumHoursBeforeService = maximumHours;
		currentHours = 0;
	}
	
	public String getSerialNumber() {
		return serialNumber;
	}
	
	public int getMaximumHoursBeforeService() {
		return maximumHoursBeforeService;
	}
	
	public int getCurrentHours() {
		return currentHours;
	}
	
	public void addHours(int moreHours) {
		currentHours += moreHours;
	}
	
	public boolean isPastTimeForService() {
		if(currentHours > maximumHoursBeforeService) {
			return true;
		}
		
		return false;
	}
	
	public int getHoursPastService() {
		if( ! isPastTimeForService()) {
			return 0;
		}
		
		int hoursPast = currentHours - maximumHoursBeforeService;
		return hoursPast;
	}
	
	@Override
	public boolean equals(Object what) {
		Motor other = (Motor) what;
		if( ! serialNumber.equals(other.serialNumber)) {
			return false;
		}
		
		return true;
	}
	
	@Override
	public int compareTo(Motor other) {
//		System.out.println("compareTo called " + this + " and " + other);
		int difference = currentHours - other.currentHours;
		
		return difference;
	}
	
	@Override
	public String toString() {
		String result = "";
		
		result += " Serial " + serialNumber;
		result += " Current Hours " + currentHours;
		
		return result;
	}
}
